#ifndef ACCOUNTMANAGER_H
#define ACCOUNTMANAGER_H
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlError>
#include <QCryptographicHash>
#include <QString>
#include <QPushButton>
#include <QMainWindow>
#include "usermanagementwidget.h"
#include "journeymodels.h"

class AccountManager {
public:
    AccountManager();
    //AccountManager();
    static QSqlDatabase& getDatabase();
    bool registerUser(const QString& username, const QString& password, const QString& contact);
    QString loginUser(const QString& username, const QString& password);
    bool userExists(const QString& username);
    QString hashPassword(const QString& password);
    bool verifyPassword(const QString& storedPassword, const QString& providedPassword);
    bool bookFlight(const QString& userID, const FlightSegment& segment);
    void setupUserManagementButton(QMainWindow* mainWindow);

    bool checkBookingInserted(const QString& userID, const FlightSegment& segment);
    bool checkJourneyInserted(const QString& userID, const FlightJourney& journey);
    bool checkFlightSegmentsInserted(int journeyID);


private:
    static QSqlDatabase db;

    AccountManager(const AccountManager&) = delete;
    void operator=(const AccountManager&) = delete;
    QPushButton* userManagementButton;
};

#endif // ACCOUNTMANAGER_H
